package com.label.web.controller.prototype;


import com.label.common.core.controller.BaseController;
import com.label.common.core.domain.AjaxResult;
import com.label.common.core.page.TableDataInfo;
import com.label.manager.domain.Job;
import com.label.manager.service.IJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/prototype/job")
public class JobController extends BaseController {

    @Autowired
    private IJobService jobService;

    /**
     * 查询题目列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Job job) {
        startPage();
        List<Job> list = jobService.selectJobList(job);
        return getDataTable(list);
    }

    /**
     * 通过题目ID查询题目信息
     */
    @GetMapping(value = "/{jobId}")
    public AjaxResult getInfo(@PathVariable Long jobId) {
        return success(jobService.selectJobById(jobId));
    }

    /**
     * 删除题目
     */
    @DeleteMapping("/{jobId}")
    public AjaxResult remove(@PathVariable Long jobId) {
        return toAjax(jobService.deleteJobById(jobId));
    }

    /**
     * 新增题目
     */
    @PostMapping
    public AjaxResult add(@RequestBody Job job) {
        return toAjax(jobService.insertJob(job));
    }

    /**
     * 修改题目
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Job job) {
        return toAjax(jobService.updateJob(job));
    }
}
